//
//  TijiaodingdanViewController.m
//  tianjin
//
//  Created by 鞠超 on 16/8/10.
//  Copyright © 2016年 jc. All rights reserved.
//

#import "TijiaodingdanViewController.h"

#import "XuanzeshouhuoViewController.h"
#import "ShangpinqingdanViewController.h"

@interface TijiaodingdanViewController () <UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate, UIScrollViewDelegate>

@property (nonatomic, strong) UITableView * tableView;

//头视图
@property (nonatomic, strong) UIView * view_head;
//
@property (nonatomic, strong) UILabel * name_user;
@property (nonatomic, strong) UILabel * tel_user;
@property (nonatomic, strong) UILabel * address_user;

//底部栏
@property (nonatomic, strong) UIView * view_bottom;
//
@property (nonatomic, strong) UILabel * number_product;
@property (nonatomic, strong) UILabel * heji_product;

//布局
@property (nonatomic, strong) UIImageView * image_1;
@property (nonatomic, strong) UIImageView * image_2;
@property (nonatomic, strong) UILabel * price_product;
@property (nonatomic, strong) UILabel * number;
//运费
@property (nonatomic, strong) UILabel * price_peisong;
//留言
@property (nonatomic, strong) UITextField * text_liuyan;
//余额
@property (nonatomic, strong) UILabel * yue;
@property (nonatomic, strong) UISwitch * switch_yue;
//
@property (nonatomic, strong) UIButton * btn_zhifubo;
@property (nonatomic, strong) UIButton * btn_weixin;

@end

@implementation TijiaodingdanViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self p_navi];
    
    [self p_setupView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navi
- (void)p_navi
{
    _btnLeft.hidden = YES;
    _lblLeft.hidden = YES;
    _btnRight.hidden = YES;
    _lblRight.hidden = YES;
    _topView.backgroundColor = [UIColor blackColor];
    
    _lblTitle.text = @"提交订单";
    _lblTitle.textColor = [UIColor whiteColor];
    _lblTitle.font = [UIFont systemFontOfSize:19];
    
    UIImageView * image_return = [[UIImageView alloc] initWithFrame:CGRectMake(15, 32, 10, 20)];
    image_return.image = [UIImage imageNamed:@"zuofanhui@2x.png"];
    [_topView addSubview:image_return];
    
    UIButton * btn_return = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_return.frame = CGRectMake(10, 20, 35, 44);
    [_topView addSubview:btn_return];
    [btn_return addTarget:self action:@selector(btn_returnAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

//左返回
- (void )btn_returnAction:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

//显示tabbar
- (void )viewWillAppear:(BOOL)animated
{
    [(AppDelegate *)[[UIApplication sharedApplication] delegate] hiddenTabBar];
}

#pragma mark - 布局
- (void )p_setupView
{
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    //底部栏
    [self p_bottomView];
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64 - 50) style:(UITableViewStylePlain)];
    self.tableView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    //头视图
    [self p_headView];
    self.tableView.tableHeaderView = self.view_head;
    self.tableView.tableFooterView = [[UIView alloc] init];
    
    [self.view addSubview:self.tableView];
}

#pragma mark - tableview代理
- (NSInteger )numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 7;
}

- (CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row == 0)
    {
        return 120;
    }
    else if(indexPath.row == 2)
    {
        return 60;
    }
    else
    {
        return 50;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell * cell = [[UITableViewCell alloc] init];
    
    if(indexPath.row == 0)
    {
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        self.image_1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 90, 90)];
        [self.image_1 sd_setImageWithURL:[NSURL URLWithString:@""] placeholderImage:[UIImage imageNamed:@"chanpingPic@2x.png"]];
        [cell addSubview:self.image_1];
        
        self.image_2 = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.image_1.frame) + 10, 10, 90, 90)];
        [self.image_2 sd_setImageWithURL:[NSURL URLWithString:@""] placeholderImage:[UIImage imageNamed:@"chanpingPic@2x.png"]];
        [cell addSubview:self.image_2];
        
        //
        self.price_product = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.image_2.frame) + 10, 35, SCREEN_WIDTH - CGRectGetMaxX(self.image_2.frame) - 10 - 30, 20)];
        self.price_product.textAlignment = NSTextAlignmentRight;
        self.price_product.text = @"￥1009.9";
        self.price_product.textColor = [UIColor redColor];
        self.price_product.font = [UIFont systemFontOfSize:17];
        [cell addSubview:self.price_product];
        
        self.number = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.image_2.frame) + 10, CGRectGetMaxY(self.price_product.frame) + 10, SCREEN_WIDTH - CGRectGetMaxX(self.image_2.frame) - 10 - 30, 15)];
        self.number.textColor = [UIColor grayColor];
        self.number.textAlignment = NSTextAlignmentRight;
        self.number.font = [UIFont systemFontOfSize:15];
        self.number.text = @"共20件";
        [cell addSubview:self.number];
        
        UIImageView * image_fanhui = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 10 - 10, 47.5, 10, 15)];
        image_fanhui.image = [UIImage imageNamed:@"dizhi_fanhui@2x.png"];
        [cell addSubview:image_fanhui];
        
        UIView * view_line = [[UIView alloc] initWithFrame:CGRectMake(0, 110, SCREEN_WIDTH, 10)];
        view_line.backgroundColor = [UIColor groupTableViewBackgroundColor];
        [cell addSubview:view_line];
    }
    else if(indexPath.row == 1)
    {
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        UILabel * name = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, 70, 20)];
        name.text = @"配送信息";
        name.font = [UIFont systemFontOfSize:16];
        [cell addSubview:name];
        
        self.price_peisong = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 10 - 100, 17.5, 100, 15)];
        self.price_peisong.text = @"配送费20元";
        self.price_peisong.textAlignment = NSTextAlignmentRight;
        self.price_peisong.font = [UIFont systemFontOfSize:14];
        self.price_peisong.textColor = [UIColor grayColor];
        [cell addSubview:self.price_peisong];
        
        UIView * view_line = [[UIView alloc] initWithFrame:CGRectMake(0, 49, SCREEN_WIDTH, 1)];
        view_line.backgroundColor = [UIColor groupTableViewBackgroundColor];
        [cell addSubview:view_line];
    }
    else if(indexPath.row == 2)
    {
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        UILabel * name = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, 70, 20)];
        name.text = @"买家留言:";
        name.font = [UIFont systemFontOfSize:16];
        [cell addSubview:name];
        
        self.text_liuyan = [[UITextField alloc] initWithFrame:CGRectMake(CGRectGetMaxX(name.frame) + 10, 15, SCREEN_WIDTH - CGRectGetMaxX(name.frame) - 20, 20)];
        self.text_liuyan.placeholder = @"还有什么吩咐请给我们留言!";
        self.text_liuyan.font = [UIFont systemFontOfSize:14];
        self.text_liuyan.clearButtonMode = UITextFieldViewModeAlways;
        self.text_liuyan.delegate = self;
        self.text_liuyan.returnKeyType = UIReturnKeyDone;
        [cell addSubview:self.text_liuyan];

        //
        UIView * view_line = [[UIView alloc] initWithFrame:CGRectMake(0, 50, SCREEN_WIDTH, 10)];
        view_line.backgroundColor = [UIColor groupTableViewBackgroundColor];
        [cell addSubview:view_line];
    }
    else if(indexPath.row == 3)
    {
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.yue = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, 200, 20)];
        self.yue.text = @"可用余额￥99.9";
        self.yue.font = [UIFont systemFontOfSize:16];
        [cell addSubview:self.yue];
        
        //
        self.switch_yue = [[UISwitch alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 10 - 50, 10, 50, 30)];
        self.switch_yue.onTintColor = [UIColor grayColor];
        [cell addSubview:self.switch_yue];
        [self.switch_yue addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
        
        //
        UIView * view_line = [[UIView alloc] initWithFrame:CGRectMake(0, 49, SCREEN_WIDTH, 1)];
        view_line.backgroundColor = [UIColor groupTableViewBackgroundColor];
        [cell addSubview:view_line];
    }
    else if(indexPath.row == 4)
    {
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        UILabel * name = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, 70, 20)];
        name.text = @"支付方式";
        name.font = [UIFont systemFontOfSize:16];
        [cell addSubview:name];
        
        UIView * view_line = [[UIView alloc] initWithFrame:CGRectMake(0, 49, SCREEN_WIDTH, 1)];
        view_line.backgroundColor = [UIColor groupTableViewBackgroundColor];
        [cell addSubview:view_line];
    }
    else if(indexPath.row == 5)
    {
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        UIImageView * image = [[UIImageView alloc] initWithFrame:CGRectMake(10, 12.5, 25, 25)];
        image.image = [UIImage imageNamed:@"zhifubo@2x.png"];
        [cell addSubview:image];
        
        UILabel * name = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image.frame) + 10, 17.5, 70, 15)];
        name.text = @"支付宝支付";
        name.font = [UIFont systemFontOfSize:13];
        [cell addSubview:name];
        
        self.btn_zhifubo = [UIButton buttonWithType:(UIButtonTypeSystem)];
        self.btn_zhifubo.frame = CGRectMake(SCREEN_WIDTH - 10 - 25, 12.5, 25, 25);
        [self.btn_zhifubo setBackgroundImage:[UIImage imageNamed:@"weixuanzhong@2x.png"] forState:(UIControlStateNormal)];
        [cell addSubview:self.btn_zhifubo];
        [self.btn_zhifubo addTarget:self action:@selector(btn_zhifuboAction:) forControlEvents:(UIControlEventTouchUpInside)];
        //
        UIView * view_line = [[UIView alloc] initWithFrame:CGRectMake(0, 49, SCREEN_WIDTH, 1)];
        view_line.backgroundColor = [UIColor groupTableViewBackgroundColor];
        [cell addSubview:view_line];
    }
    else if(indexPath.row == 6)
    {
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        UIImageView * image = [[UIImageView alloc] initWithFrame:CGRectMake(10, 12.5, 25, 25)];
        image.image = [UIImage imageNamed:@"weixin@2x.png"];
        [cell addSubview:image];
        
        UILabel * name = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image.frame) + 10, 17.5, 70, 15)];
        name.text = @"微信支付";
        name.font = [UIFont systemFontOfSize:13];
        [cell addSubview:name];
        
        self.btn_weixin = [UIButton buttonWithType:(UIButtonTypeSystem)];
        self.btn_weixin.frame = CGRectMake(SCREEN_WIDTH - 10 - 25, 12.5, 25, 25);
        [self.btn_weixin setBackgroundImage:[UIImage imageNamed:@"weixuanzhong@2x.png"] forState:(UIControlStateNormal)];
        [cell addSubview:self.btn_weixin];
        [self.btn_weixin addTarget:self action:@selector(btn_weixinAction:) forControlEvents:(UIControlEventTouchUpInside)];
        //
        UIView * view_line = [[UIView alloc] initWithFrame:CGRectMake(0, 49, SCREEN_WIDTH, 1)];
        view_line.backgroundColor = [UIColor groupTableViewBackgroundColor];
        [cell addSubview:view_line];
    }
    
    return cell;
}

- (void )tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if(indexPath.row == 0)
    {
//        NSLog(@"点击进入购物产品清单");
        
        ShangpinqingdanViewController * shangpinqingdanViewController = [[ShangpinqingdanViewController alloc] init];
        [self showViewController:shangpinqingdanViewController sender:nil];
    }
}

#pragma mark - 支付宝
- (void )btn_zhifuboAction:(UIButton *)sender
{
    if([sender.currentBackgroundImage isEqual:[UIImage imageNamed:@"weixuanzhong@2x.png"]])
    {
        [self.btn_zhifubo setBackgroundImage:[UIImage imageNamed:@"xuanzhong@2x.png"] forState:(UIControlStateNormal)];
        
        //
        [self.btn_weixin setBackgroundImage:[UIImage imageNamed:@"weixuanzhong@2x.png"] forState:(UIControlStateNormal)];
        self.switch_yue.on = NO;
    }
    else
    {
        [self.btn_zhifubo setBackgroundImage:[UIImage imageNamed:@"weixuanzhong@2x.png"] forState:(UIControlStateNormal)];
    }
}

#pragma mark - 微信
- (void )btn_weixinAction:(UIButton *)sender
{
    if([sender.currentBackgroundImage isEqual:[UIImage imageNamed:@"weixuanzhong@2x.png"]])
    {
        [self.btn_weixin setBackgroundImage:[UIImage imageNamed:@"xuanzhong@2x.png"] forState:(UIControlStateNormal)];
        
        //
        [self.btn_zhifubo setBackgroundImage:[UIImage imageNamed:@"weixuanzhong@2x.png"] forState:(UIControlStateNormal)];
        self.switch_yue.on = NO;
    }
    else
    {
        [self.btn_weixin setBackgroundImage:[UIImage imageNamed:@"weixuanzhong@2x.png"] forState:(UIControlStateNormal)];
    }
}

#pragma mark - switch(余额)
- (void )switchAction:(UISwitch *)sender
{
    if(sender.selected == YES)
    {
        sender.on = NO;
    }
    else
    {
        sender.on = YES;
        
        [self.btn_weixin setBackgroundImage:[UIImage imageNamed:@"weixuanzhong@2x.png"] forState:(UIControlStateNormal)];
        [self.btn_zhifubo setBackgroundImage:[UIImage imageNamed:@"weixuanzhong@2x.png"] forState:(UIControlStateNormal)];
    }
}

#pragma mark - 跳转收货管理页面
- (void )dingzhiAction:(id )sender
{
//    NSLog(@"跳转收货管理页面");
    
    XuanzeshouhuoViewController * xuanzeshouhuoViewController = [[XuanzeshouhuoViewController alloc] init];
    [self showViewController:xuanzeshouhuoViewController sender:nil];
}

#pragma mark - 提交订单
- (void )btn_tijiaodingdanAction:(UIButton *)sender
{
    NSLog(@"提交订单");
}

#pragma mark - 头视图
- (void )p_headView
{
    self.view_head = [[UIView alloc] init];
    self.view_head.backgroundColor = [UIColor whiteColor];
    
    //手势
    UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dingzhiAction:)];
    tapGesture.numberOfTapsRequired = 1; //点击次数
    tapGesture.numberOfTouchesRequired = 1; //点击手指数
    [self.view_head addGestureRecognizer:tapGesture];
    
    //无地址
    self.view_head.frame = CGRectMake(0, 0, SCREEN_WIDTH, 110);
    
//    //有地址
//    self.view_head.frame = CGRectMake(0, 0, SCREEN_WIDTH, 125);
    
    //上面线
    UIView * view_line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
    view_line.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.view_head addSubview:view_line];
    
    UIImageView * image_line = [[UIImageView alloc] initWithFrame:CGRectMake(0, 10, SCREEN_WIDTH, 2)];
    image_line.image = [UIImage imageNamed:@"line_1@2x.png"];
    [self.view_head addSubview:image_line];

    //下面线
    UIImageView * image_line1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, self.view_head.frame.size.height - 12, SCREEN_WIDTH, 2)];
    image_line1.image = [UIImage imageNamed:@"line_1@2x.png"];
    [self.view_head addSubview:image_line1];
    
    UIView * view_line1 = [[UIView alloc] initWithFrame:CGRectMake(0, self.view_head.frame.size.height - 10, SCREEN_WIDTH, 10)];
    view_line1.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.view_head addSubview:view_line1];
    
    //
    UILabel * shouhuodizhi = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(image_line.frame) + 10, SCREEN_WIDTH - 30, 20)];
    shouhuodizhi.text = @"收货地址";
    shouhuodizhi.font = [UIFont systemFontOfSize:17];
    [self.view_head addSubview:shouhuodizhi];
    
    UIView * view_Line = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(shouhuodizhi.frame) + 10, SCREEN_WIDTH, 1)];
    view_Line.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.view_head addSubview:view_Line];
    
    //无地址
    UIImageView * image_dizhi = [[UIImageView alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(view_Line.frame) + 12, 15, 20)];
    image_dizhi.image = [UIImage imageNamed:@"dingdan_dizhi@2x.png"];
    [self.view_head addSubview:image_dizhi];

    UILabel * lbl_dizhi = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_dizhi.frame) + 5, CGRectGetMaxY(view_Line.frame) + 12, 200, 20)];
    lbl_dizhi.text = @"请添加收货地址";
    lbl_dizhi.font = [UIFont systemFontOfSize:17];
    [self.view_head addSubview:lbl_dizhi];
    
    
//    //有地址
//    UIImageView * image_dizhi = [[UIImageView alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(view_Line.frame) + 20, 15, 20)];
//    image_dizhi.image = [UIImage imageNamed:@"dingdan_dizhi@2x.png"];
//    [self.view_head addSubview:image_dizhi];
//
//    UIImageView * image_fanhui = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 10 - 10, CGRectGetMaxY(view_Line.frame) + 23, 10, 15)];
//    image_fanhui.image = [UIImage imageNamed:@"dizhi_fanhui@2x.png"];
//    [self.view_head addSubview:image_fanhui];
//    
//    CGFloat length_x = (SCREEN_WIDTH - CGRectGetMaxX(image_dizhi.frame) - 10 - 30) / 2;
//
//    self.name_user = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_dizhi.frame) + 10, CGRectGetMaxY(view_Line.frame) + 10, length_x, 15)];
//    self.name_user.text = @"sdjksjksjkjkjdksj";
//    self.name_user.font = [UIFont systemFontOfSize:15];
//    [self.view_head addSubview:self.name_user];
//    
//    self.tel_user = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.name_user.frame), CGRectGetMaxY(view_Line.frame) + 10, length_x, 15)];
//    self.tel_user.text = @"12345678988";
//    self.tel_user.font = [UIFont systemFontOfSize:15];
//    self.tel_user.textAlignment = NSTextAlignmentRight;
//    [self.view_head addSubview:self.tel_user];
//    
//    self.address_user = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_dizhi.frame) + 10, CGRectGetMaxY(self.name_user.frame) + 10, length_x * 2, 15)];
//    self.address_user.font = [UIFont systemFontOfSize:15];
//    self.address_user.text = @"山东省临沂市兰山区山东省临沂市兰山区";
//    [self.view_head addSubview:self.address_user];
}

#pragma mark - 底部栏
- (void )p_bottomView
{
    self.view_bottom = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - 50, SCREEN_WIDTH, 50)];
    self.view_bottom.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.view_bottom];
    
    UIView * view_line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 1)];
    view_line.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.view_bottom addSubview:view_line];
    
    self.number_product = [[UILabel alloc] initWithFrame:CGRectMake(15, 15, 90, 20)];
    self.number_product.font = [UIFont systemFontOfSize:15];
    self.number_product.text = @"共2件商品";
    [self.view_bottom addSubview:self.number_product];
    
    UILabel * heji = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.number_product.frame), 15, 40, 20)];
    heji.text = @"合计:";
    heji.font = [UIFont systemFontOfSize:15];
    heji.textColor = [UIColor grayColor];
    [self.view_bottom addSubview:heji];
    
    self.heji_product = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(heji.frame), 15, SCREEN_WIDTH - CGRectGetMaxX(heji.frame) - SCREEN_WIDTH / 4 - 10, 20)];
    self.heji_product.text = @"￥1909.9";
    self.heji_product.font = [UIFont systemFontOfSize:17];
    self.heji_product.textColor = [UIColor redColor];
    [self.view_bottom addSubview:self.heji_product];
    
    UIButton * btn_tijiaodingdan = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_tijiaodingdan.frame = CGRectMake(SCREEN_WIDTH / 4 * 3, 0, SCREEN_WIDTH / 4, 50);
    btn_tijiaodingdan.backgroundColor = navi_bar_bg_color;
    [btn_tijiaodingdan setTitle:@"提交订单" forState:(UIControlStateNormal)];
    [btn_tijiaodingdan setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    [self.view_bottom addSubview:btn_tijiaodingdan];
    [btn_tijiaodingdan addTarget:self action:@selector(btn_tijiaodingdanAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

#pragma mark - textField代理
- (BOOL )textFieldShouldBeginEditing:(UITextField *)textField
{
    if(SCREEN_WIDTH == 320)
    {
        [UIView animateWithDuration:0.7 animations:^{
            
            self.tableView.contentOffset = CGPointMake(0, 220);
            
        } completion:^(BOOL finished) {
            
        }];
    }
    else if(SCREEN_WIDTH == 375)
    {
        [UIView animateWithDuration:0.7 animations:^{
            
            self.tableView.contentOffset = CGPointMake(0, 100);
            
        } completion:^(BOOL finished) {
            
        }];
    }
    else
    {
        [UIView animateWithDuration:0.7 animations:^{
            
            self.tableView.contentOffset = CGPointMake(0, 30);
            
        } completion:^(BOOL finished) {
            
        }];
    }
    
    return YES;
}

- (BOOL )textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    
    [UIView animateWithDuration:0.7 animations:^{
        
        self.tableView.contentOffset = CGPointMake(0, 0);
        
    } completion:^(BOOL finished) {
        
    }];
    
    return YES;
}

- (void )scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    [self.text_liuyan resignFirstResponder];
}












@end
